<form name="search-courses" id="search-courses" method="get" action="">
	<fieldset id="simple-search-options">
		<div class="legend" id="search-course-leg">Search the LFCC Course List</div>
		<fieldset>
			<fieldset class="optgroup">
            	<div class="checkbox" style=" width: 40%;">
                	<input type="checkbox" class="checkbox" name="reset-search" id="reset-search" value="true" />
                    <label for="reset-search">Reset all search criteria</label>
                </div>
            	<div class="checkbox" style=" width: 40%;">
                	<input type="checkbox" class="checkbox" name="opencourses" id="opencourses" value="true"<?php echo (isset($_GET['opencourses']) && $_GET['opencourses'] == 'true') ? ' checked="checked"' : ''; ?> />
                    <label for="opencourses">Show only courses that are still available</label>
                </div>
            </fieldset>
<?php
if(count($terms) > 1) {
	echo '
		<div class="legend">Show only courses offered during the following academic term(s):</div>
		<div class="note">Please select all that apply</div>
		<fieldset class="optgroup">';

	foreach($terms as $k=>$t) {
		$selected = (in_array($k,$formterms)) ? ' checked="checked"' : '';
		echo '
			<div class="checkbox">
				<input type="checkbox" class="checkbox" name="STRM[]" id="STRM_'.$k.'" value="'.$k.'"'.$selected.' />
				<label for="STRM_'.$k.'">'.$t.'</label>
			</div>';
	}

	echo '
		</fieldset>';
}

if(in_array('MIDDLETOWN',$locations) || in_array('FAUQUIER',$locations) || in_array('LPCC',$locations) || in_array('VIRTUAL',$locations)) {
	$lfcc_locations = array();
	foreach(array('MIDDLETOWN','FAUQUIER','LPCC','VIRTUAL') as $l) {
		if(in_array($l,$locations)) {
			$lfcc_locations[] = $l;
			unset($locations[array_search($l,$locations)]);
		}
	}
	echo '
		<div class="legend">Show only courses offered at the following LFCC location(s):</div>
		<div class="note">Please select all that apply</div>
		<fieldset class="optgroup">';
	foreach($lfcc_locations as $l) {
		$selected = (in_array($l,$formlocs)) ? ' checked="checked"' : '';
		echo '
			<div class="checkbox">
				<input type="checkbox" class="checkbox" name="LOCATION[]" id="LOCATION_'.strtolower($l).'" value="'.$l.'"'.$selected.' />
				<label for="LOCATION_'.strtolower($l).'">'.$course_locations[strtoupper($l)].'</label>
			</div>';
	}

	echo '
		</fieldset>';
}
echo '
		<div class="legend">Show only courses offered at the following off-site location(s):</div>
		<div class="note">Please select all that apply</div>
		<fieldset class="optgroup">';
foreach($locations as $l) {
	$selected = (in_array($l,$formlocs)) ? ' checked="checked"' : '';
	echo '
			<div class="checkbox">
				<input type="checkbox" class="checkbox" name="LOCATION[]" id="LOCATION_'.strtolower($l).'" value="'.$l.'"'.$selected.' />
				<label for="LOCATION_'.strtolower($l).'">'.$course_locations[strtoupper($l)].'</label>
			</div>';
}

echo '
		</fieldset>';
?>
			<label for="search-course-subjects" style="width: auto; clear: both; float: none;">Subject:</label>
			<div class="note">Please select all that apply</div>
			<select name="SUBJECT[]" id="search-course-subjects" multiple="multiple" style="width: 98%; float: none; clear: both;" size="10">
<?php
foreach($course_subjects as $d=>$v) {
	$s = (isset($_GET['SUBJECT']) && is_array($_GET['SUBJECT']) && in_array($d,$_GET['SUBJECT'])) ? ' selected="selected"' : '';
	echo '
				<option value="'.$d.'"'.$s.'>'.htmlentities($v,ENT_QUOTES).'</option>';
}
?>
			</select>
	</fieldset>
    <fieldset id="adv-search-options">
        	<div class="legend">Show only courses with the following name:</div>
			<label for="search-course-classname">Course Name:</label>
			<input type="text" name="COURSE_TITLE_LONG" id="search-course-classname" value="<?php echo (isset($_GET['COURSE_TITLE_LONG'])) ? $_GET['COURSE_TITLE_LONG'] : ''; ?>" />
			<fieldset class="optgroup">
				<div class="legend">Show courses being offered on the following days:</div>
				<div class="note">Please select all that apply</div>
<?php
foreach($course_days as $d=>$v) {
	echo '
				<div class="checkbox">
					<input type="checkbox" class="checkbox" name="LUE[]" id="search-course-days_'.$d.'"';
	echo (isset($_GET['LUE']) && is_array($_GET['LUE']) && in_array($d,$_GET['LUE'])) ? ' checked="checked"' : '';
	echo ' value="'.$d.'" /><label for="search-course-days_'.$d.'">'.$v.'</label>
				</div>';
}
?>
			</fieldset>
            <fieldset class="optgroup">
            	<div class="legend">Show courses that begin at the following times:</div>
				<div class="note">Please select all that apply</div>
<?php
foreach(array(12=>'before noon',16=>'noon to 4 p.m.',23=>'after 4 p.m.') as $k=>$v) {
	echo '
				<div class="checkbox">
					<input type="checkbox" class="checkbox" name="STIME[]" id="search-course-times_'.$k.'"';
	echo (isset($_GET['STIME']) && is_array($_GET['STIME']) && in_array($k,$_GET['STIME'])) ? ' checked="checked"' : '';
	echo ' value="'.$k.'" /><label for="search-course-times_'.$k.'">'.$v.'</label>
				</div>';
}
?>
            </fieldset>
            <br />
        	<div class="legend">Show only courses taught by the following instructor:</div>
			<label for="search-course-instructor">Instructor Name:</label>
			<input type="text" name="INSTRUCTORNAME" id="search-course-instructor" value="<?php echo (isset($_GET['INSTRUCTORNAME'])) ? $_GET['INSTRUCTORNAME'] : ''; ?>" />
		</fieldset>
<?php
echo '
	<fieldset id="howmanyopts">
		Show ';

echo '
		<select name="howmany" id="howmany" style="width: 5em; float: none; display: inline;">';
$i = array(25,50,100,200,250,500,1000,1500,2000);
foreach($i as $j) {
	$s = ($howmany == $j) ? ' selected="selected"' : '';
	echo '
			<option value="'.$j.'"'.$s.'>'.$j.'</option>';
}
unset($i);
echo '
		</select>';

echo ' records per page.
	</fieldset>';
?>
	</fieldset>
	<input type="submit" name="submit-course-search" id="submit-course-search" value="Search" class="submit" />
</form>